﻿@* Generator: Template
    GeneratePrettyNames : true *@
@functions{
    public NFinal.Compile.Template.App.Code.Data.CookieManagerModel Model { get; set; }
}
//======================================================================
//
//        Copyright : Zhengzhou Strawberry Computer Technology Co.,LTD.
//        All rights reserved
//        
//        Application:NFinal MVC framework
//        Filename :CookieManager.cs
//        Description :Cookie管理类
//
//        created by Lucas at  2015-6-30`
//     
//        WebSite:http://www.nfinal.com
//
//======================================================================
using System;
using System.Collections.Generic;
using System.Web;

namespace @{@Model.project}.@{@Model.app}.Code.Data
{
    public class CookieManager:NFinal.Cookie
    {
		private CookieInfo _cookieInfo = new CookieInfo();
        public CookieManager()
        {
        }
        public CookieManager(NFinal.IAction action):base(action)
        {
            
        }
        public CookieManager(IDictionary<string, string> cookies):base(cookies)
        {

        }
        @foreach(var declaraton in Model.declarations){
        @:public @{@declaraton.typeName} @{@declaraton.varName}
        @:{
            @:get
            @:{
				if(declaraton.isString){
					@:_cookieInfo.@{@declaraton.varName} = this["@{@declaraton.varName}"];
				}else{
					@:@{@declaraton.typeName}.TryParse(this["@{@declaraton.varName}"],out _cookieInfo.@{@declaraton.varName});
				}
				@:return _cookieInfo.@{@declaraton.varName};
            @:}
            @:set
            @:{
                @:_cookieInfo.@{@declaraton.varName} = value;
				if(declaraton.isString){
					@:this["@{@Model.cookiePrefix}@{@declaraton.varName}"]= value;
				}else{
					@:this["@{@Model.cookiePrefix}@{@declaraton.varName}"]= value.ToString();
				}
            @:}
        @:}
        }
    }
}